<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>培训机构管理系统</title>
<link rel="stylesheet" type="text/css"
	href="EXT4/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css"
	href="css/style.css" />
<script type="text/javascript" src="EXT4/ext-all.js"></script>
<script type="text/javascript" src="script/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
Ext.onReady(function() {
	var store = Ext.create('Ext.data.TreeStore', {
        proxy: {
            type: 'ajax',
            url: 'service/getmenu.action'
        },
        autoLoad: true,
        sorters: [{
            property: 'index',
            direction: 'ASC'
        }]
    });
	
	var tabs=Ext.widget('tabpanel', {
        activeTab: 0,
        defaults :{
            bodyPadding: 2
        },
        region: 'center',
        margin:'0 5 0 0',
        items: [{
            title: '系统门户',
        }],
        plugins: Ext.create('Ext.ux.TabCloseMenu', {
            closeTabText: '关闭当前',
            closeOthersTabsText: '关闭其他',
            closeAllTabsText: '关闭所有'
        }),
        listeners:{
        	'tabchange':function(tabPanel, newCard, oldCard){
        		var newframe =Ext.getDom('frame'+newCard.getId());
        		if(newframe!=null){
        			newframe.src=newframe.src;
        		}
        	}
        }
    });
	
	Ext.create('Ext.Viewport', {
        layout: {
            type: 'border',
        },
        defaults: {
            split: true
        },
        items: [{
            region: 'north',
            id:'title',
            contentEl:'Banner',
            height:75,
            split: false,
            margin:'0 5 0 5',
        },Ext.create('Ext.tree.Panel', {
        		id:'menu',
            	store: store,
                rootVisible: false,
                useArrows: true,
                region: 'west',
                collapsible: true,
                title: '导航栏',
                split: true,
                width: 200,
                minWidth: 150,
                maxWidth: 250,
                margin:'0 0 0 5',
                listeners : {  
                    'itemclick' : function(view,record){
                    	if(record.data.leaf){
                    		var tab=tabs.getComponent(record.data.id);
                    		if(!tab){
                    			tabs.add({
                                    title: record.data.text,
                                    id: record.data.id,
                                    closable: true,
                                    html:'<iframe id="frame'+record.data.id+'" frameborder="0" height="100%" width="100%" src="'+record.data.hrefTarget+'"></iframe>',
                                }).show();
                    		}else{
                    			tab.show();
                    		}
                    	}
                    }  
                }
            }),
            tabs
            ,{
            region: 'south',
            height:35,
            contentEl:'copyright',
            margin:'5 5 5 5',
            split: false
        }]
    });
});

function hideorshow(){
	var value=Ext.getDom('istitlehide').value;
	if(value=="1"){
		Ext.getDom('istitlehide').value="0";
		Ext.getCmp("title").setHeight(23);
	}else{
		Ext.getDom('istitlehide').value="1";
		Ext.getCmp("title").setHeight(75);
	}
}

function collapseprexpand(){
	var value=Ext.getDom('ismenucollapse').value;
	if(value=="1"){
		Ext.getDom('ismenucollapse').value="0";
		Ext.getCmp("title").setHeight(23);
		Ext.getCmp("menu").collapse();
		window.setWidth(window.width);
	}else{
		Ext.getDom('ismenucollapse').value="1";
		Ext.getCmp("menu").expand();
		Ext.getCmp("title").setHeight(75);
		window.setWidth(window.width);
	}
}

function logout(){
	 Ext.MessageBox.confirm('提示', '是否退出系统', function callBack(result) {
		 if(result=='yes'){
			 window.location.href='logout.action';
		 }
     });
}

</script>
</head>
<body>

	<input type="hidden" id="istitlehide" value="1"/>
	
	<input type="hidden" id="ismenucollapse" value="1"/>
	
	<div id="Banner" class="banner">
		<div class="logo"></div>
		<div class="menu">
			<div class="menuleft"></div>
			<div class="menumid">
			<img alt="" src="images/user.png"></div>
			<div class="username"><s:property value="username"/></div>
			<div class="space">|</div>
			<div class="menumid">
			<a href='javascript:hideorshow()'>
			<img alt="" src="images/up_down.png">
			</a>
			</div>
			<div class="space">|</div>
			<div class="menumid">
			<a href='javascript:collapseprexpand()'>
			<img alt="" src="images/arrow_expand.png">
			</a>
			</div>
			<div class="space">|</div>
			<div class="menumid">
			<a href='javascript:logout()'>
			<img alt="" src="images/bt-logout.png">
			</a>
			</div>
			<div class="menuright"></div>
		</div>
	</div>
	<div id="copyright" class="copyright">
		<center></center>
	</div>
</body>
</html>